package com.shjn.squirrel.model;

import com.shjn.squirrel.bean.httpBean.ParamBean;
import com.shjn.squirrel.bean.otherBean.RecyclerRecord;

import java.util.ArrayList;
import java.util.LinkedHashMap;

/**
 * 回收员信息缓存
 */
public class RecyclerInfoCache {

    private RecyclerInfoCache() {
    }

    /**
     * 回收员登录状态
     */
    public static Boolean loginState = false;

    /**
     * 回收员账号
     */
    public static String telNum;

    /**
     * 回收员选择的垃圾种类及其相关参数
     */
    public static RecyclerRecord garbageParam = new RecyclerRecord();

    /**
     * 回收员可用余额
     */
    public static double balance;

    /**
     * 回收员首次进入垃圾选择页面
     */
    public static boolean firstSelect = true;

    /**
     * 回收员首次进入垃圾选择页面时，垃圾分类桶状态
     */
    public static ArrayList<ParamBean> canState = new ArrayList<>();

    /**
     * 回收员回收记录
     */
    public static LinkedHashMap<String, Double> records = new LinkedHashMap<>();

    /**
     * 默认垃圾空桶，常温状态
     */
    static {
        initCanState();
    }

    /**
     * 添加回收员回收记录
     */
    public static void addRecord() {

        if (!RecyclerInfoCache.records.containsKey(garbageParam.getCategory())) {
            RecyclerInfoCache.records.put(garbageParam.getCategory(), garbageParam.getQuantity());
        }

    }

    /**
     * 清空本次回收员信息
     */
    public static void clearRecyclerInfo() {
        loginState = false;
        telNum = null;
        garbageParam = new RecyclerRecord();
        balance = 0;
        firstSelect = true;
        initCanState();
        RecyclerInfoCache.records.clear();
    }

    /**
     * 默认垃圾空桶，常温状态
     */
    public static void initCanState(){
        canState.clear();
        for (int i = 0; i < 8; i++) {
            canState.add(new ParamBean(i+1,0,0,0,0));
        }
    }
}
